<script setup lang="ts">
import { onMounted, ref } from 'vue';
import { getIcon } from "@/api/assets/assets";

// 导入静态图片
// import img301 from '@/assets/301.png';
// import img302 from '@/assets/302.png';

const img301 = ref<string | undefined>(undefined)
const img302 = ref<string | undefined>(undefined)

const fetchIcon = async () => {
  try {
    const data = await getIcon(['301.png', '302.png'])
    img301.value = data['301.png']
    img302.value = data['302.png']
  }
  catch (error) {
    console.error('API 调用错误:', error)
  }
}
onMounted(() => {
  fetchIcon()
})

const tabs = ['智绘心康', '智诚研盾']
const activeTab = ref('智绘心康')

const setActiveTab = (tab: string) => {
  activeTab.value = tab
}
</script>

<template>
  <div class="star-project-section">
    <div class="section-header">
      <div class="line left-line" />
      <h2 class="title">
        明星项目引领创新
      </h2>
      <div class="line right-line" />
    </div>
    <div class="description">
      <p>明星项目引领创新：展示杰出创新项目，激发无限创意，助力学生走在创新最前沿。</p>
    </div>
    <div class="tabs">
      <div
        v-for="tab in tabs"
        :key="tab"
        class="tab"
        :class="[activeTab === tab ? 'active-tab' : '']"
        @click="setActiveTab(tab)"
      >
        {{ tab }}
        <div v-if="activeTab === tab" class="tab-underline" />
      </div>
    </div>
    <div v-if="activeTab === '智绘心康'" class="tab-content">
      <div class="text-content">
        <p class="project-sub-description">
          Star projects lead innovation
        </p>
        <h3 class="project-title">
          智绘心康
        </h3>
        <p class="project-description">
          AI赋能乡村医养，实现精准化逻辑循证、个性化慢病检测和智能化交互问诊，提供全生命周期健康管理。
        </p>
      </div>
      <div class="right-content">
        <img :src="img301" alt="智绘心康" class="project-image">
      </div>
    </div>
    <div v-if="activeTab === '智诚研盾'" class="tab-content">
      <div class="text-content">
        <p class="project-sub-description">
          Star projects lead innovation
        </p>
        <h3 class="project-title">
          智诚研盾
        </h3>
        <p class="project-description">
          综合性学术不端行为检测平台，利用AI技术自动识别论文中的图片、公式等元素，提升审稿效率与准确性。
        </p>
      </div>
      <div class="right-content">
        <img :src="img302" alt="智诚研盾" class="project-image">
      </div>
    </div>
  </div>
</template>

<style scoped>
.star-project-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 1920px;
  padding: 50px 0;
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 20px;
}

.line {
  width: 107px;
  height: 0;
  border: 1px solid;
  opacity: 1;
}

.left-line {
  border-image-source: linear-gradient(270deg, rgba(102, 102, 102, 0) 0%, #000000 100%);
  border-image-slice: 1;
  transform: rotate(180deg);
  margin-right: 20px;
  margin-top: 20px;
}

.right-line {
  border-image-source: linear-gradient(270deg, #000000 0%, rgba(102, 102, 102, 0) 100%);
  border-image-slice: 1;
  margin-left: 20px;
  transform: rotate(180deg);
  margin-top: 20px;
}

.title {
  font-family: 'Alimama ShuHeiTi', sans-serif;
  font-size: 44px;
  font-weight: 700;
  line-height: 34px;
  color: #3f3f3f;
  white-space: nowrap;
}

.description {
  font-family: 'Alibaba PuHuiTi', sans-serif;
  font-size: 16px;
  font-weight: 400;
  line-height: 22px;
  color: #86869f;
  text-align: center;
  width: 800px;
  margin-top: 10px;
  margin-bottom: 50px;
}

.tabs {
  display: flex;
  justify-content: center;
  gap: 100px;
  margin-bottom: 30px;
}

.tab {
  font-family: 'Alibaba PuHuiTi', sans-serif;
  font-size: 20px;
  font-weight: 400;
  line-height: 27.44px;
  text-align: center;
  color: #000000;
  cursor: pointer;
}

.active-tab {
  font-weight: 700;
  color: #4b79db;
}

.tab-underline {
  width: 124.29px;
  height: 0;
  border: 3px solid #4894e7;
  margin-top: 5px;
}

.tab-content {
  display: flex;
  width: 100%;
}

.text-content {
  min-width: 950px;
  max-width: 950px;
  min-height: 550px;
  max-height: 550px;
  background: linear-gradient(269.86deg, #4a8de3 2.75%, #3bbafc 99.87%);
  padding: 20px;
  color: white;
}

.project-sub-description {
  font-family: 'Roboto', sans-serif;
  font-size: 47px;
  font-weight: 800;
  line-height: 55.08px;
  color: #ffffff4d;
  margin-left: 250px;
  margin-top: 100px;
}

.project-title {
  font-family: 'Alimama ShuHeiTi', sans-serif;
  font-size: 36px;
  font-weight: 700;
  line-height: 44.14px;
  color: #ffffff;
  margin-left: 250px;
  margin-top: 0px;
}

.project-description {
  font-family: 'Alibaba PuHuiTi', sans-serif;
  font-size: 16px;
  font-weight: 400;
  line-height: 24px;
  color: #daeaFa;
  margin-bottom: 50px;
  margin-left: 250px;
  margin-right: 150px;
}

.right-content {
  flex: 1;
}

.project-image {
  width: 100%;
  height: 550px;
  object-fit: cover;
}
</style>
